package com.software.graduationproject.commons.enums;

import com.v2coding.validate.BaseEnum;

import java.util.ArrayList;
import java.util.List;


/**
 * MerchantType : 商家类型
 * ---------------------------------------------------------------------------------------------------------------------
 */
public enum MerchantType implements BaseEnum<MerchantType, Integer> {
    ALL("全部", 0),
    CHAOS_DUMPLINGS("混沌饺子", 1),
    HAMBURGER_FRIES("汉堡薯条", 2),
    PASTA_PIZZA("意面披萨", 3),
    STEAMED_BUNS_CONGEE("包子粥店", 4),
    FAST_FOOD_BENTO("快餐便当", 5),
    RICE_NOODLE_NOODLE_SHOP("米粉面馆", 6),
    SPICY_HOT_POT("麻辣烫冒菜", 7),
    SICHUAN_HUNAN_CUISINE("川湘菜", 8),
    FRIED_CHICKEN_SKWER("炸鸡炸串", 9),
    LIGHT_FOOD_SALAD("轻食沙拉", 10),
    DESSERT_DRINK("甜点饮品", 11),
    LOBSTER_BARBECUE("龙虾烧烤", 12),
    DUCK_NECK_LUWEI("鸭脖卤味", 13),
    JAPANESE_SUSHI("日料寿司", 14),
    KOREAN_CUISINE("韩式料理", 15),
    SPICY_DRY_POT("香辣干锅", 16),

    ERROR("数据错误", -1);

    private final String label;
    private final Integer value;

    MerchantType(String label, Integer value) {
        this.label = label;
        this.value = value;
    }

    @Override
    public Integer getValue() {
        return this.value;
    }

    @Override
    public String getLabel() {
        return this.label;
    }

    @Override
    public MerchantType getEnum(Integer value) {
        if (null == value) {
            return ERROR;
        }
        for (MerchantType e : values()) {
            if (e.value.equals(value)) {
                return e;
            }
        }
        return ERROR;
    }

    public static List<Integer> searchValuesByKeyword(String keyword) {
        List<Integer> matches = new ArrayList<>();
        for (MerchantType type : MerchantType.values()) {
            if (type.label.contains(keyword)) {
                matches.add(type.value);
            }
        }
        return matches;
    }
}
